import { SUCCESS_CODE } from '@/core/constants/coreConstants'
import { R } from '@/components/axios/interface'
import IamAccountProfileResponse from '@/core/account/generated/types/model/response/IamAccountProfileResponse'
import { MockMethod } from 'vite-plugin-mock'
import mockProdServerUtils from '../utils/mockUtils'
import accountApiConfig from '@/core/account/apiconfig/accountApiConfig'

const timeout = 50
const mockList = [
	{
		url: accountApiConfig.admin.iamAccountProfileGetByCurrentAccount.mockUri,
		method: accountApiConfig.admin.iamAccountProfileGetByCurrentAccount.method,
		timeout,
		response: () => {
			return {
				code: SUCCESS_CODE,
				data: {
					id: '1',
					iamAppId: '1',
					accountId: '1',
					nickName: 'admin',
					realName: 'admin',
					avatar: '/src/assets/images/avatar.png',
					signature: '',
					sex: 0,
					registerSourceFrom: 0,
					birthday: null,
					deleteFlag: '0',
					createTime: new Date().getTime().toString(),
					updateTime: new Date().getTime().toString(),
					rowVersion: 1,
				} as IamAccountProfileResponse,
			}
		},
	},
	{
		url: accountApiConfig.admin.iamAccountPasswordModifyPassword.mockUri,
		method: accountApiConfig.admin.iamAccountPasswordModifyPassword.method,
		timeout,
		response: () => {
			const rnd = Math.floor(Math.random() * 2) + 1
			if (rnd === 1) {
				return {
					code: SUCCESS_CODE,
					message: '成功',
				} as R
			} else {
				return {
					code: 1,
					message: '密码错误',
				} as R
			}
		},
	},
] as MockMethod[]

mockProdServerUtils.addPriorityMockList(1, ...mockList)
